package com.cssy.yd.logic.dao.impl;

import com.cssy.yd.logic.dao.LogicPriceDAO;
import com.cssy.yd.logic.entity.LogicPriceDO;
import com.plat.helper.SearchConditions;

import java.util.List;

import org.springframework.dao.DataAccessException;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

/**
 * 数据访问对象实现类
 * @since 2012-12-26
 */
public class LogicPriceDAOImpl extends SqlMapClientDaoSupport implements LogicPriceDAO {

    /**
     * 插入数据
     * @param logicPriceDO
     * @return 插入数据的主键
     */
    public void insertLogicPriceDO(LogicPriceDO logicPriceDO) {
        getSqlMapClientTemplate().insert("LogicPrice.insert", logicPriceDO);
    }

    /**
     * 统计记录数
     * @param logicPriceDO
     * @return 查出的记录数
     */
    public Integer countLogicPriceDOByExample(LogicPriceDO logicPriceDO) {
        Integer count = (Integer) getSqlMapClientTemplate().queryForObject("LogicPrice.countByDOExample", logicPriceDO);
        return count;
    }

    /**
     * 获取对象列表
     * @param logicPriceDO
     * @return 对象列表
     */
    @SuppressWarnings("unchecked")
    public List<LogicPriceDO> findListByExample(LogicPriceDO logicPriceDO) {
        List<LogicPriceDO> list = getSqlMapClientTemplate().queryForList("LogicPrice.findListByDO", logicPriceDO);
        return list;
    }
    
    /**
     * 更新记录
     * @param logicPriceDO
     * @return 受影响的行数
     */
    public Integer updateLogicPriceDO(LogicPriceDO logicPriceDO) throws DataAccessException {
        int result = getSqlMapClientTemplate().update("LogicPrice.update", logicPriceDO);
        return result;
    }

    
    /**
     * 根据主键获取logicPriceDO
     * @param id
     * @return logicPriceDO
     */
    public LogicPriceDO findLogicPriceDOByPrimaryKey(String id) throws DataAccessException {
    	LogicPriceDO logicPriceDO = (LogicPriceDO) getSqlMapClientTemplate().queryForObject("LogicPrice.findByPrimaryKey", id);
        return logicPriceDO;
    }

    /**
     * 删除记录
     * @param id
     * @return 受影响的行数
     */
    public Integer deleteLogicPriceDOByPrimaryKey(String id) throws DataAccessException {
        Integer rows = (Integer) getSqlMapClientTemplate().delete("LogicPrice.deleteByPrimaryKey", id);
        return rows;
    }
    
    @Override
	public List<LogicPriceDO> find(SearchConditions scs)
			throws DataAccessException {
		List<LogicPriceDO> list = getSqlMapClientTemplate().queryForList("LogicPrice_ex.find", scs);
		return list;
	}

	@Override
	public Integer count(SearchConditions scs) throws DataAccessException {
		 Integer count = (Integer) getSqlMapClientTemplate().queryForObject("LogicPrice_ex.count", scs);
		return count;
	}
}